package com.smedi.ismedi.constructionproject.api.feign;

import com.smedi.ismedi.constructionproject.api.dto.request.*;
import com.smedi.ismedi.constructionproject.api.dto.response.ProjectBasicResponse;
import com.smedi.ismedi.constructionproject.api.dto.response.ProjectTreeResponse;
import com.smedi.ismedi.constructionproject.api.dto.response.resp.ProjectDetailResp;
import com.smedi.ismedi.constructionproject.api.dto.response.resp.ProjectResp;
import com.smedi.ismedi.constructionproject.api.dto.response.resp.ProjectWithDingResp;
import com.smedi.ismedi.web.starter.common.PaginationData;
import com.smedi.ismedi.web.starter.common.ResponseData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.time.LocalDate;
import java.util.List;

@Api(tags = {"项目管理接口"})
@FeignClient(name = "ismedi-construction-project")
@RequestMapping(value = "/api/v1/construction-project")
public interface RemoteConstructionProjectFeignApi {
    /**
     * 保存项目信息
     *
     * @param projectBasicRequest 项目信息
     * @return ResponseData<ProjectBasicResponse>
     */
    @ApiOperation(httpMethod = "POST", value = "保存项目信息")
    @PostMapping(value = "/saveProject")
    ResponseData<ProjectBasicResponse> postSaveProjectInfo(@Validated @RequestBody ProjectBasicRequest projectBasicRequest);

    /**
     * 更新 项目 信息
     *
     * @param projectBasicUpdateRequest 项目更新信息
     * @return ResponseData<ProjectBasicResponse>
     */
    @ApiOperation(httpMethod = "POST", value = "更新 项目 信息")
    @PostMapping(value = "/updateProjectInfo")
    ResponseData<Boolean> updateProjectInfo(@Valid @RequestBody ProjectBasicUpdateRequest projectBasicUpdateRequest);

    /**
     * 项目组织界面查询项目分页信息
     *
     * @param offset
     * @param pageSize
     * @param projectName
     * @param projectCode
     * @param projectManager
     * @param hrOrganizationId
     * @param containHrOrganizationChildren
     * @return
     */
    @ApiOperation(httpMethod = "GET", value = "项目组织界面查询项目分页信息")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "offset", value = "页码", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(paramType = "query", name = "pageSize", value = "每页行数", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(paramType = "query", name = "projectName", value = "项目名称", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(paramType = "query", name = "projectCode", value = "项目编码", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(paramType = "query", name = "projectManager", value = "项目经理", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(paramType = "query", name = "hrOrganizationId", value = "企业组织id", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(paramType = "query", name = "containHrOrganizationChildren", value = "包含下级", dataType = "Boolean", allowableValues = "true, false", dataTypeClass = Boolean.class),
    })
    @GetMapping(value = "/queryProjectPagination")
    ResponseData<PaginationData> getQueryProjectPagination(@RequestParam("offset") Long offset,
                                                           @RequestParam("pageSize") Long pageSize,
                                                           @RequestParam(value = "projectName", required = false) String projectName,
                                                           @RequestParam(value = "projectCode", required = false) String projectCode,
                                                           @RequestParam(value = "projectManager", required = false) String projectManager,
                                                           @RequestParam(value = "hrOrganizationId") Long hrOrganizationId,
                                                           @RequestParam(value = "containHrOrganizationChildren", required = false) boolean containHrOrganizationChildren);

    /**
     * 查询项目信息
     *
     * @param projectId
     * @return
     */
    @ApiOperation(httpMethod = "GET", value = "查询项目信息")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "projectId", value = "项目id", dataType = "Long", dataTypeClass = Long.class)
    })
    @GetMapping(value = "/getQueryProjectBasicView")
    @Deprecated
    ResponseData<ProjectBasicResponse> getQueryProjectBasicView(@RequestParam("projectId") Long projectId);

    /**
     * 查询项目信息
     *
     * @param provinceName
     * @return
     */
    @ApiOperation(httpMethod = "GET", value = "查询项目信息")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "provinceName", value = "省份名称", dataType = "String", dataTypeClass = String.class)
    })
    @GetMapping(value = "/getQueryProjectBasicViewByProvinceName")
    @Deprecated
    ResponseData<List<ProjectBasicResponse>> getQueryProjectBasicView(@RequestParam(value = "provinceName", required = false) String provinceName);


    /**
     * 判断项目是否可以用
     *
     * @param projectId
     * @return
     */
    @ApiOperation(httpMethod = "GET", value = "判断项目是否可以用")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "projectId", value = "项目id", dataType = "Long", dataTypeClass = Long.class)
    })
    @GetMapping(value = "/checkProjectAvailable")
    ResponseData<Boolean> getCheckProjectAvailable(@RequestParam("projectId") Long projectId);

    /**
     * 判断组织下是否含有项目信息
     *
     * @param hrOrganizationId
     * @return
     */
    @ApiOperation(httpMethod = "GET", value = "判断组织下是否含有项目信息")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "hrOrganizationId", value = "企业组织id", dataType = "Long", dataTypeClass = Long.class)
    })
    @GetMapping(value = "/checkHrOrganizationHasProject")
    ResponseData<Boolean> getCheckHrOrganizationHasProject(@RequestParam("hrOrganizationId") Long hrOrganizationId);

    /**
     * 项目管理界面查询项目分页信息
     *
     * @param offset
     * @param pageSize
     * @param projectName
     * @param projectCode
     * @param projectManager
     * @param hrOrganizationId
     * @param projectStatus
     * @param projectCategory
     * @param contractDurationBegin
     * @param contractDurationEnd
     * @return
     */
    @ApiOperation(httpMethod = "GET", value = "项目管理界面查询项目分页信息")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "offset", value = "页码", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(paramType = "query", name = "pageSize", value = "每页行数", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(paramType = "query", name = "projectName", value = "项目名称", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(paramType = "query", name = "projectCode", value = "项目编码", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(paramType = "query", name = "projectManager", value = "项目经理", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(paramType = "query", name = "hrOrganizationId", value = "企业组织id", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(paramType = "query", name = "supervisionUnit", value = "施工监理单位", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(paramType = "query", name = "projectStatus", value = "工程状态", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(paramType = "query", name = "projectCategory", value = "工程类别", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(paramType = "query", name = "contractDurationBegin", value = "合同工期开始：YYYY-MM-DD", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(paramType = "query", name = "contractDurationEnd", value = "合同工期结束：YYYY-MM-DD", dataType = "String", dataTypeClass = String.class),
    })
    @GetMapping(value = "/queryProjectManagementInfoPagination")
    ResponseData<PaginationData> getQueryProjectManagementInfoPagination(@RequestParam("offset") Long offset,
                                                                         @RequestParam("pageSize") Long pageSize,
                                                                         @RequestParam(value = "projectName", required = false) String projectName,
                                                                         @RequestParam(value = "projectCode", required = false) String projectCode,
                                                                         @RequestParam(value = "projectManager", required = false) String projectManager,
                                                                         @RequestParam(value = "hrOrganizationId", required = false) Long hrOrganizationId,
                                                                         @RequestParam(value = "supervisionUnit", required = false) String supervisionUnit,
                                                                         @RequestParam(value = "projectStatus", required = false) String projectStatus,
                                                                         @RequestParam(value = "projectCategory", required = false) String projectCategory,
                                                                         @RequestParam(value = "contractDurationBegin", required = false) String contractDurationBegin,
                                                                         @RequestParam(value = "contractDurationEnd", required = false) String contractDurationEnd);


    /**
     * 项目管理界面查询项目分页信息
     *
     * @param offset
     * @param pageSize
     * @param projectName
     * @param projectCode
     * @param projectManager
     * @param hrOrganizationId
     * @param projectStatus
     * @param projectCategory
     * @param contractDurationBegin
     * @param contractDurationEnd
     * @return
     */
    @ApiOperation(httpMethod = "GET", value = "项目管理界面查询项目分页信息")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "offset", value = "页码", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(paramType = "query", name = "pageSize", value = "每页行数", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(paramType = "query", name = "projectName", value = "项目名称", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(paramType = "query", name = "projectCode", value = "项目编码", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(paramType = "query", name = "projectManager", value = "项目经理", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(paramType = "query", name = "hrOrganizationId", value = "企业组织id", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(paramType = "query", name = "supervisionUnit", value = "施工监理单位", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(paramType = "query", name = "projectStatus", value = "工程状态", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(paramType = "query", name = "projectCategory", value = "工程类别", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(paramType = "query", name = "contractDurationBegin", value = "合同工期开始：YYYY-MM-DD", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(paramType = "query", name = "contractDurationEnd", value = "合同工期结束：YYYY-MM-DD", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(paramType = "query", name = "epcType", value = "总承包模式", dataType = "String", dataTypeClass = String.class)
    })
    @GetMapping(value = "/queryProjectManagementInfoPaginationForMobile")
    ResponseData<PaginationData> getQueryProjectManagementInfoPaginationForMobile(@RequestParam("offset") Long offset,
                                                                                  @RequestParam("pageSize") Long pageSize,
                                                                                  @RequestParam(value = "projectName", required = false) String projectName,
                                                                                  @RequestParam(value = "projectCode", required = false) String projectCode,
                                                                                  @RequestParam(value = "projectManager", required = false) String projectManager,
                                                                                  @RequestParam(value = "hrOrganizationId", required = false) Long hrOrganizationId,
                                                                                  @RequestParam(value = "supervisionUnit", required = false) String supervisionUnit,
                                                                                  @RequestParam(value = "projectStatus", required = false) String projectStatus,
                                                                                  @RequestParam(value = "projectCategory", required = false) String projectCategory,
                                                                                  @RequestParam(value = "contractDurationBegin", required = false) String contractDurationBegin,
                                                                                  @RequestParam(value = "contractDurationEnd", required = false) String contractDurationEnd,
                                                                                  @RequestParam(value = "epcType", required = false) String epcType);


    /**
     * 获取所有项目列表
     *
     * @return
     */
    @ApiOperation(httpMethod = "GET", value = "获取所有项目列表")
    @GetMapping(value = "/queryAvailableProjectBasicList")
    @Deprecated
    ResponseData<List<ProjectBasicResponse>> getQueryAvailableProjectBasicList();

    /**
     * 获取所有项目列表带token
     *
     * @return
     */
    @ApiOperation(httpMethod = "GET", value = "获取所有项目列表")
    @GetMapping(value = "/queryAvailableProjectBasicListWithToken")
    @Deprecated
    ResponseData<List<ProjectBasicResponse>> getQueryAvailableProjectBasicListWithToken();

    /**
     * 获取企业组织下的项目数据列表
     *
     * @return
     */
    @ApiOperation(httpMethod = "GET", value = "获取企业组织下的项目数据列表")
    @GetMapping(value = "/getProjectTreeWithHrOrganizations")
    ResponseData<ProjectTreeResponse> getProjectTreeWithHrOrganizations();

    /**
     * 删除项目、项目分配、项目标段信息
     *
     * @param projectId
     * @return
     */
    @ApiOperation(httpMethod = "DELETE", value = "删除项目、项目分配、项目标段信息")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "projectId", value = "项目id", dataType = "Long", dataTypeClass = Long.class),
    })
    @DeleteMapping(value = "/deleteProjectAllInfos")
    ResponseData<Boolean> deleteProjectAllInfos(@RequestParam("projectId") Long projectId);

    /**
     * 根据传入的企业组织id数组获取项目清单
     *
     * @param hrOrganizationIds
     * @return
     */
    @ApiOperation(httpMethod = "GET", value = "根据传入的企业组织id数组获取项目清单")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "hrOrganizationIds", value = "企业组织id数组", dataType = "List", dataTypeClass = List.class),
    })
    @GetMapping(value = "/queryProjectBasicListByHrOrganizationIds")
    @Deprecated
    ResponseData<List<ProjectBasicResponse>> getQueryProjectBasicListByHrOrganizationIds(@RequestParam("hrOrganizationIds") List<Long> hrOrganizationIds);

    /**
     * 根据传入的人员id获取项目列表
     *
     * @param personId
     * @return
     */
    @ApiOperation(httpMethod = "GET", value = "根据传入的人员id获取项目列表")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "personId", value = "人员id", dataType = "Long", dataTypeClass = Long.class),
    })
    @GetMapping(value = "/queryProjectBasicListByPersonId")
    @Deprecated
    ResponseData<List<ProjectBasicResponse>> getQueryProjectBasicListByPersonId(@RequestParam("personId") Long personId);

    /**
     * 根据传入的企业组织id获取项目列表
     *
     * @param hrOrganizationId
     * @return
     */
    @ApiOperation(httpMethod = "GET", value = "根据传入的企业组织id获取项目列表")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "hrOrganizationId", value = "企业组织id", dataType = "Long", dataTypeClass = Long.class),
    })
    @GetMapping(value = "/getQueryProjectBasicListByHrOrganizationId")
    @Deprecated
    ResponseData<List<ProjectBasicResponse>> getQueryProjectBasicListByHrOrganizationId(@RequestParam("hrOrganizationId") Long hrOrganizationId);

    /**
     * 根据传入的项目名称/项目经理名称获取项目列表
     *
     * @param appSearch
     * @return
     */
    @ApiOperation(httpMethod = "GET", value = "根据传入的项目名称/项目经理名称获取项目列表")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "appSearch", value = "项目名称/项目经理名称", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(paramType = "query", name = "ids", value = "项目ID", dataType = "Long", dataTypeClass = Long.class),
    })
    @GetMapping(value = "/getQueryProjectBasicListByApp")
    ResponseData<List<ProjectBasicResponse>> getQueryProjectBasicListByApp(@RequestParam("appSearch") String appSearch,@RequestParam("ids") List<Long> ids);

    /**
     * 更新形象进度
     *
     * @param
     * @return
     */
    @ApiOperation(httpMethod = "POST", value = "更新形象进度")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "projectId", value = "项目Id", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(paramType = "query", name = "vividProgress", value = "形象进度", dataType = "int", dataTypeClass = Integer.class),
            @ApiImplicitParam(paramType = "query", name = "vividProgressUpdatedDate", value = "形象进度更新时间", dataType = "date", dataTypeClass = LocalDate.class),
    })
    @PostMapping(value = "/saveVividProgress")
    ResponseData<ProjectBasicResponse> postSaveVividProgress(@RequestParam("projectId") Long projectId,
                                                             @RequestParam("vividProgress") int vividProgress,
                                                             @RequestParam("vividProgressUpdatedDate") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate vividProgressUpdatedDate);

    /**
     * 上传区域照片
     *
     * @param
     * @return
     */
    @ApiOperation(httpMethod = "POST", value = "上传区域照片")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "projectId", value = "项目Id", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(paramType = "query", name = "regionPicture", value = "区域照片signKey", dataType = "String", dataTypeClass = Integer.class)
    })
    @PostMapping(value = "/postSaveRegionPicture")
    ResponseData<ProjectBasicResponse> postSaveRegionPicture(@RequestParam("projectId") Long projectId,
                                                             @RequestParam("regionPicture") String regionPicture);

    /**
     * 上传组织机构照片
     *
     * @param
     * @return
     */
    @ApiOperation(httpMethod = "POST", value = "上传组织机构照片")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "projectId", value = "项目Id", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(paramType = "query", name = "organizationPicture", value = "组织机构照片signKey", dataType = "String", dataTypeClass = Integer.class)
    })
    @PostMapping(value = "/postSaveOrganizationPicture")
    ResponseData<ProjectBasicResponse> postSaveOrganizationPicture(@RequestParam("projectId") Long projectId,
                                                                   @RequestParam("organizationPicture") String organizationPicture);

    /**
     * 上传安全责任委托书
     *
     * @param
     * @return
     */
    @ApiOperation(httpMethod = "POST", value = "上传安全责任委托书")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "projectId", value = "项目Id", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(paramType = "query", name = "entrustBook", value = "安全责任委托书signKey", dataType = "String", dataTypeClass = Integer.class)
    })
    @PostMapping(value = "/postSaveEntrustBook")
    ResponseData<ProjectBasicResponse> postSaveEntrustBook(@RequestParam("projectId") Long projectId,
                                                           @RequestParam("entrustBook") String entrustBook);


    /**
     * 设置监控类型
     *
     * @param
     * @return
     */
    @ApiOperation(httpMethod = "POST", value = "设置监控类型")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "projectId", value = "项目Id", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(paramType = "query", name = "monitorType", value = "监控类型", dataType = "String", dataTypeClass = String.class),
    })
    @PostMapping(value = "/saveMonitorType")
    ResponseData<ProjectBasicResponse> postSaveMonitorType(@RequestParam("projectId") Long projectId,
                                                           @RequestParam("monitorType") String monitorType,
                                                           @RequestParam(value = "monitorTypeNote", required = false) String monitorTypeNote);

    /**
     * 查询 项目 单一
     *
     * @param projectOneQueryRequest 项目单一查询条件
     * @return ResponseData<ProjectResp>
     */
    @ApiOperation(httpMethod = "POST", value = "查询 项目 单一")
    @PostMapping(value = "/getProjectOne")
    ResponseData<ProjectResp> getProjectOne(@Valid @RequestBody ProjectOneQueryRequest projectOneQueryRequest);

    /**
     * 查询 项目 列表
     *
     * @param projectListQueryRequest 项目列表查询条件
     * @return ResponseData<List < ProjectResp>>
     */
    @ApiOperation(httpMethod = "POST", value = "查询 项目 列表")
    @PostMapping(value = "/getProjectList")
    ResponseData<List<ProjectResp>> getProjectList(@Valid @RequestBody ProjectListQueryRequest projectListQueryRequest);

    /**
     * 查询 项目 分页
     *
     * @param projectPageQueryRequest 项目 分页 查询条件
     * @return ResponseData<List < ProjectResp>>
     */
    @ApiOperation(httpMethod = "POST", value = "查询 项目（详细） 分页")
    @PostMapping(value = "/getProjectDetailPage")
    ResponseData<PaginationData<ProjectDetailResp>> getProjectDetailPage(@Valid @RequestBody ProjectPageQueryRequest projectPageQueryRequest);

    /**
     * 查询 项目（详情） 列表
     *
     * @param projectListQueryRequest 项目列表查询条件
     * @return ResponseData<List < ProjectResp>>
     */
    @ApiOperation(httpMethod = "POST", value = "查询 项目 列表")
    @PostMapping(value = "/getProjectDetailList")
    ResponseData<List<ProjectDetailResp>> getProjectDetailList(@Valid @RequestBody ProjectListQueryRequest projectListQueryRequest);

    /**
     * 查询 项目 列表
     *
     * @param projectListQueryRequest 项目列表查询条件
     * @return ResponseData<List < ProjectResp>>
     */
    @ApiOperation(httpMethod = "POST", value = "查询 项目 列表（不需要token）")
    @PostMapping(value = "/getProjectListWithoutToken")
    ResponseData<List<ProjectResp>> getProjectListWithoutToken(@Valid @RequestBody ProjectListQueryRequest projectListQueryRequest);

    @PostMapping("/updateByName")
    @ApiOperation(httpMethod = "POST", value = "更新 项目钉钉Key")
    ResponseData<Long> updateByName(@RequestBody ConstructionProjectUpdateRequest orgUpdateRequest);

    @GetMapping("/project/{orgId}")
    @ApiOperation(httpMethod = "GET", value = "查询 项目 列表")
    ResponseData<List<ProjectWithDingResp>> getProjectResponseDataByOrgId(@PathVariable Long orgId);

    @GetMapping("/project/one/{id}")
    @ApiOperation(httpMethod = "GET", value = "查询 项目 单个")
    ResponseData<ProjectWithDingResp> getProjectWithDing(@PathVariable Long id);

    @PostMapping("/count")
    @ApiOperation(httpMethod = "POST", value = "统计 项目 数量")
    ResponseData<Integer> getProjectCount(@Valid @RequestBody ProjectCountQueryRequest projectCountQueryRequest);
}
